package test;

//打印出[2,34,556,34,64,54,23]
public class test1 {
    public static void main(String[] args) {
        //定义数组
        int[] arr = {2, 34, 556, 34, 64, 54, 23};
        printArr(arr);
    }

    public static void printArr(int[] arr) {

        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                System.out.print(arr[i]);
            } else {
                System.out.print(arr[i] + ",");
            }

        }
        System.out.print("]");
    }
}

